package com.example.demo.controller;


import com.example.demo.domain.Category;
import com.example.demo.repository.CateGoryRepository;
import com.example.demo.service.CateGoryService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping(value = "/cgc")
public class CateGoryController {

    private final static Logger logger = LoggerFactory.getLogger(CateGoryController.class);

    @Autowired
    private CateGoryRepository cateGoryRepository;

    @Autowired
    private CateGoryService cateGoryService;
    @RequestMapping("/toCateGory")
    public String toCateGory(){
        return "/view/category";
    }

    @RequestMapping(value = "/getAllData")
    @ResponseBody
    public Object cateGoryList(int offset, int limit) {
        return cateGoryService.getPageCateGory(offset,limit,"");
    }
    @RequestMapping(value = "/getData")
    @ResponseBody
    public Object cateGoryList(int offset, int limit,String mess ) {
        return cateGoryService.getPageCateGory(offset,limit,mess);
    }
    @RequestMapping(value = "/insertData")
    @ResponseBody
    public Object insertCateGory(Category category) {
        return cateGoryService.insertCategory(category);
    }
    @RequestMapping(value = "/editData")
    @ResponseBody
    public Object editCateGory(Category category) {
        return cateGoryService.insertCategory(category);
    }
    @RequestMapping(value = "/deleteData")
    @ResponseBody
    public Object deleteCateGory(int id) {
        return cateGoryService.deleteCategory(id);
    }


}
